home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / e / mailinglists / amigae.0294feb.archive / 000048_donews!crash!h…m.ac.uk!dmh1002_Sat, 12 Feb 94 04:13:00 PST.msg < prev    next >
Internet Message Format  |  1994-05-26  |  2KB

  1. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  2.       id <1taq@bkhouse.cts.com>; Sat, 12 Feb 94 04:13:00 PST
  3. Received: from crash by donews.cts.com with uucp
  4.     (Smail3.1.28.1 #18) id m0pVIYJ-0001mhC; Sat, 12 Feb 94 06:30 EST
  5. Received: from ppsw2.cam.ac.uk by crash.cts.com with smtp
  6.     (Smail3.1.28.1 #18) id m0pVILM-0000TzC; Sat, 12 Feb 94 03:17 PST
  7. Received: from black.csi.cam.ac.uk by ppsw2.cam.ac.uk 
  8.           with SMTP-CAM (PP-6.0) as ppsw.cam.ac.uk 
  9.           id <08479-0@ppsw2.cam.ac.uk>; Sat, 12 Feb 1994 11:16:30 +0000
  10. Received: from hermes.cam.ac.uk by black.csi.cam.ac.uk 
  11.           id <24735-0@black.csi.cam.ac.uk>; Sat, 12 Feb 1994 11:15:56 +0000
  12. Date: Sat, 12 Feb 1994 11:17:00 +0000 (GMT)
  13. In-Reply-To: <5883:77010@fantasyfarm.com>
  14. Message-ID: <Pine.3.89.9402121106.A15308-0100000@blue.csi.cam.ac.uk>
  15. MIME-Version: 1.0
  16. Content-Type: TEXT/PLAIN; charset=US-ASCII
  17. Sender: dmh1002@hermes.cam.ac.uk
  18. From: Dave Higginson <dmh1002@hermes.cam.ac.uk>
  19. To: The AmigaE Mailing List <AmigaE@bkhouse.cts.com>
  20. Subject: Re: Bugs in the Mod() function
  21.  
  22.  
  23. On Wed, 9 Feb 1994, Bernie Cosell wrote:
  24.  
  25. > After a lot of debugging of code that ought to have worked, I
  26. > discovered that the Mod function seems to be VERY broken.  As we
  27. > [ought to] all know, taking an integer mod N should *always* get you
  28. > an integer between 0 and n-1.  Well, it ain't so in E.  A simple
  29. > test reveals:
  30.  
  31. In fact the Mod function is not broken at all. Virtually all mod 
  32. functions in computer languages work in the fashion you have described. 
  33. You'll just have to find a workaround if you want a strictly positive 
  34. answer, I'm afraid. You could try Mod(Mod(a,n)+n,n). Or, if your n is a 
  35. power of 2, use (a and (n-1)).
  36.  
  37. > Which is clearly broken.  In the course of pursuing this, I discovered
  38. > that simple division ain't a prize, either:
  39. > Dividing 11 / 8 = 1
  40. > Dividing 6 / 8 = 0
  41. > Dividing 1 / 8 = 0
  42. > Dividing -4 / 8 = 0
  43. > Dividing -9 / 8 = -1
  44. > Dividing -14 / 8 = -1
  45.  
  46. What answers were you expecting???
  47.  
  48. > It is astounding to me to try to understand arithmetic in an environment
  49. > where:
  50. >     (A - B) / B  does *NOT* equal (A / B) - 1
  51.  
  52. Ermm ... actually I think it does. Can you give an example where E does 
  53. not exhibit this behaviour?
  54.  
  55. Dave
  56.  
  57. +--
  58.   // David Higginson, dmh1002@hermes.cam.ac.uk
  59. \X/  Churchill College, Cambridge, CB3 0DS, UK